<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/18
 * Time: 14:52
 */
// 创建tcp对象
$client = new \Swoole\Client(SWOOLE_SOCK_TCP);
//链接tcp
$connectCode=$client->connect('127.0.0.1',9510,0.5);
if ($connectCode) {
    // php cli 模式
    fwrite(STDOUT,'请输入消息：');
    //获取cli模式输入的消息
    $content = trim(fgetc(STDIN));
    //发送消息
    $client->send($content);
    //接受消息
    $resMsg = $client->recv();
    var_dump($resMsg);
}else{
    echo '链接失败';
}
